var olnav = document.querySelector('.ol-nav')
var as = document.querySelectorAll('.ol-nav a')
olnav.onclick = function(e) {
    if (e.target.localName == "a") {
        index = e.target.dataset.a
    }
    for (var i = 0; i < as.length; i++) {
        as[i].classList.remove('active')
    }
    as[index].classList.add('active')
}

var img1 = document.querySelector('.img1')
var img2 = document.querySelector('.img2')
var img3 = document.querySelector('.img3')
var img4 = document.querySelector('.img4')
var img5 = document.querySelector('.img5')
var img6 = document.querySelector('.img6')
var img1_meng2 = document.querySelector('.img1 .meng.meng2')
var img2_meng2 = document.querySelector('.img2 .meng.meng2')
var img3_meng2 = document.querySelector('.img3 .meng.meng2')
var img4_meng2 = document.querySelector('.img4 .meng.meng2')
var img5_meng2 = document.querySelector('.img5 .meng.meng2')
var img6_meng2 = document.querySelector('.img6 .meng.meng2')

function rise(x, y) {

    x.onmouseover = function() {
        y.style.bottom = '0px'
    }
    x.onmouseout = function() {
        y.style.bottom = '-100%'
    }
}
rise(img1, img1_meng2);
rise(img2, img2_meng2);
rise(img3, img3_meng2);
rise(img4, img4_meng2);
rise(img5, img5_meng2);
rise(img6, img6_meng2);

var lis = document.querySelectorAll('.tag-tit-ul li')
var links = document.querySelectorAll('.link-con')

for (var i = 0; i < lis.length; i++) {
    lis[i].index = i;
    lis[i].onmousemove = function() {
        for (var j = 0; j < links.length; j++) {
            lis[j].className = '';
            links[j].style.display = 'none';
        }
        this.className = 'current'
        links[this.index].style.display = 'block';
    }
}



var suggest = document.querySelector('.suggest')
var link = document.querySelector('.suggest .link')
var to_top = document.querySelector('.to-top')
suggest.onmouseover = function() {
    link.style.display = 'block'
}
suggest.onmouseout = function() {
    link.style.display = 'none'
}


function
getScrollTop() {
    var scroll_top = 0;
    if (document.documentElement && document.documentElement.scrollTop) { //如果非IE
        scroll_top = document.documentElement.scrollTop;
    } else if (document.body) { //IE浏览器
        scroll_top = document.body.scrollTop;
    };
    return scroll_top;
};

var subnav = document.querySelector('.sub-nav-con')
window.onscroll = function() {

    if (getScrollTop() > 124) {
        subnav.style.position = 'fixed'
        subnav.style.top = '0px'
        subnav.style.zIndex = '99'
            // subnav.style.left = '200px'
    } else {
        subnav.style.position = ''
        subnav.style.top = ''
        subnav.style.zIndex = ''
    }
    if (getScrollTop() > 600) {
        to_top.classList.add('show')
    } else {
        to_top.classList.remove('show')
    }

};
to_top.onclick = function() {
    timer = setInterval(function() {
        var osTop = document.documentElement.scrollTop || document.body.scrollTop;
        var ispeed = Math.floor(-osTop / 5);
        document.documentElement.scrollTop = document.body.scrollTop = osTop + ispeed;
        isTop = true;
        if (osTop == 0) {
            clearInterval(timer);
        }
    }, 30);
}